import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.LinkedList;
import java.util.NoSuchElementException;

/**
 * @author Navin
 * 
 * A block of memory...
 */
public final class IOBlock {

	public static void main(String[] args) throws IOException {
		IOBlock iob = new IOBlock();
		OutputStream p = iob.getOutputStream();
		p.write(100);// println(s.nextLine());
		System.out.println(iob.getInputStream().read());
	}

	/**
	 * @param args
	 */

	private final LinkedList<Integer> block = new LinkedList<Integer>();

	private final InputStream in = new InputStream() {
		@Override
		public int read() throws IOException {
			try {
				return block.pop();
			} catch (NoSuchElementException e) {
				return -1;
			}
		}
	};

	private final OutputStream out = new OutputStream() {

		@Override
		public void write(int b) throws IOException {
			block.add(b);
		}
	};

	/**
	 * @return the InputStream
	 */
	public InputStream getInputStream() {
		return in;
	}

	/**
	 * @return the OutputStream
	 */
	public OutputStream getOutputStream() {
		return out;
	}

}
